package com.huike.web.controller.report;


import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import com.huike.report.domain.vo.IndexBaseInfoVO;
import com.huike.report.domain.vo.IndexTodayInfoVO;
import com.huike.report.domain.vo.IndexTodoInfoVO;
import com.huike.report.domain.vo.IndexVo;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import javax.annotation.PostConstruct;
import java.time.LocalDate;
import java.util.Date;
import java.util.concurrent.CompletableFuture;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        String username = SecurityUtils.getUsername();
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime, username));
        //return AjaxResult.success(join);
    }

    /**
     * @return com.huike.common.core.domain.AjaxResult
     * @author chenqingxu
     * @description 获取当前用户的今日简报中的数据
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
//        获取当前用户
        String username = SecurityUtils.getUsername();
//        获取当前的时间只需要“yyyy-MM-dd"
        String currentTime = DateUtils.getDate();
        IndexTodayInfoVO todayInfo = reportService.getTodayInfo(currentTime, username);
        return AjaxResult.success(reportService.getTodayInfo(currentTime, username));
    }

    /**
     * @Description
     * @Retrurn
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime
    ) {
        String username = SecurityUtils.getUsername();
        IndexTodoInfoVO todoInfo = reportService.getTodoInfo(beginCreateTime, endCreateTime, username);
        return AjaxResult.success(todoInfo);
    }
}